package com.pj.wisdomlogistics.mvp.presenter;


import com.pj.wisdomlogistics.entity.TakeoutMenuInfo;
import com.pj.wisdomlogistics.entity.WeekSsMenuInfo;
import com.pj.wisdomlogistics.mvp.contract.TakeoutMealContract;
import com.pj.wisdomlogistics.mvp.frame.ActivityPresenter;
import com.pj.wisdomlogistics.mvp.model.TakeoutMealModel;
import com.pj.wisdomlogistics.rx.FilterSubscriber;

import java.util.List;


public class TakeoutMealPresenter extends ActivityPresenter<TakeoutMealModel,TakeoutMealContract.View> implements TakeoutMealContract.Presenter{
    public static final String TAG = "TakeoutMealPresenter";

    @Override
    public void findOutFoodList(int place) {
        addSubscription(getModel().findOutFoodList(place), new FilterSubscriber<TakeoutMenuInfo>() {
            @Override
            public void onNext(TakeoutMenuInfo mMenuInfo) {
                getView().showMenuSuccess(mMenuInfo);
            }

            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().showError(errorMsg);
            }

        });
    }

    @Override
    public void findCookFoodList() {
        addSubscription(getModel().findCookFoodList(), new FilterSubscriber<List<WeekSsMenuInfo>>() {
            @Override
            public void onNext(List<WeekSsMenuInfo> mWeekSsMenuInfos) {
                getView().showWeekMenuSuccess(mWeekSsMenuInfos);
            }

            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().showError(errorMsg);
            }

        });
    }

    @Override
    public void submitFoodApply(String cookFood , String outFood, String userId, int place) {
        addSubscription(getModel().submitFoodApply(cookFood ,outFood, userId, place), new FilterSubscriber() {
            @Override
            public void onNext(Object mO) {
                getView().showSendSuccess();
            }

            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().showError(errorMsg);
            }

        });
    }

    @Override
    public void getTimestamp() {
        addSubscription(getModel().getTimestamp(), new FilterSubscriber<String>() {
            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().showError(errorMsg);
            }

            @Override
            public void onNext(String o) {
                getView().getTimeSuccess(o);
            }
        });
    }
}
